#include <stdio.h>
#include <errno.h>
#include <stdlib.h>

int main(int argc, char const *argv[])
{
    char filename[256] = {0};
    printf("请输入一个文件名，c语言程序将试图以追加权限打开：\n");
    scanf("%s", filename);
    FILE *fp = fopen(filename, "a");
    if (fp == NULL)
    {
        printf("文件打开出错，当前errno=%d\n", errno);
        perror("main()");
        exit(1);
    }
    printf("文件打开成功\n");
    fclose(fp);
    return 0;
}

